#ifndef UNIVERSE_H_
#define UNIVERSE_H_

#include <iostream>
#include <list>
#include <iterator>
#include <vector>
using namespace std;

#include "Shell.h"
#include "Position.h"

class Universe
{
public:
    Universe(unsigned int sizeX, unsigned int sizeY);
    virtual ~Universe();

    bool moveElementTo(Shell * shell, const Direction & dir);
    bool moveElementTo(Shell * shell, const Position & position);

    bool registerElement(Shell * newElement);
    void deleteElement(Shell * newElement);
    
    Shell * getElementAt(const Position & position); 
    
    bool ActiveElementExistsAt(const Position & position) const;
    
    // send a spawn signal to all elements
    void spawnAllElements();
    
//    const Element * getElementAt(const Position & pos) const;

    unsigned int getYsize() const;
    unsigned int getXsize() const;
    
    bool isOutsideUniverse(const Position & pos) const;
    bool isOutsideUniverse(const Position & pos, const Direction & dir) const;

private:
    //2D matrix with all elements
    
    vector<vector<list<Shell *> > > matrix;
    list<Shell *> elements;
    
    unsigned int sizeX;
    unsigned int sizeY;
//    unsigned int Zsize;
};

#endif /*UNIVERSE_H_*/
